﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.Models;

namespace Core.Repositories
{
    public class UserRepository : Repository<User, DatabaseEntities>
    {
        //private static List<User> _userList = new List<User>
        //{
        //    new User{ Id = 1, UserName = "admin", Password = "123"},
        //    new User{ Id = 2, UserName = "anbinhtrong", Password = "123"}
        //};

        //public bool Validate(string username, string password)
        //{
        //    var user = _userList.FirstOrDefault(t => t.UserName == username);
        //    if (user == null)
        //    {
        //        return false;
        //    }
        //    if (user.Password == password)
        //    {
        //        return true;
        //    }
        //    return false;
        //}

        public bool Validate(string username, string password)
        {
            var user = GetOne(t => t.UserName == username);
            if (user == null)
            {
                return false;
            }
            if (user.Password == password)
            {
                return true;
            }
            return false;
        }
    }
}
